const logger = require('../console-logger')
const { doRequest } = require('../http-utils')

const userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.20(0x18001434) NetType/WIFI Language/en";
const headers = {
  'User-Agent': userAgent,
  'Referer': 'https://servicewechat.com/wx2f9b06c1de1ccfca/84/page-frame.html',
  'Accept-Encoding': 'gzip,compress,deflate',
  'content-type': 'application/json'
};
let apiKey = "";
let baseUrl = "https://frodo.douban.com/api/v2";

function setup(setConfig) {
  // default
  apiKey = "";
  baseUrl = "https://frodo.douban.com/api/v2";

  if (setConfig) {
    setConfig.apiKey && (apiKey = setConfig.apiKey);
    setConfig.host &&  (baseUrl = setConfig.host);
  }
  if (!apiKey) {
    logger.info('豆瓣 apikey 未设置')
  } else {
    logger.info('豆瓣 服务启动')
  }
}

function call(options) {
  const requestOptions = {
    method: options.method || 'get',
    url: options.url,
    baseURL: baseUrl,
    headers,
    params: {
      apiKey,
      ...options.params,
      _ts: new Date().getTime(),
    },
    timeout: 10000,
  }
  if (options.data) {
    requestOptions.data = options.data 
  }
  return new Promise((resolve, reject) => {
    doRequest(requestOptions)
      .then(function (response) {
        resolve(response);
      })
      .catch(function (error) {
        logger.error('doRequest error: ', error)
        resolve(null);
      })
  });
}


// search
// items[index].target
/*
 {
  rating: { count: 7871, max: 10, star_count: 3.5, value: 7.2 },
  controversy_reason: '',
  title: '完美世界',
  abstract: '',
  has_linewatch: true,
  uri: 'douban://douban.com/tv/35312003',
  cover_url: 'https://qnmob3.doubanio.com/view/photo/large/public/p2616542621.jpg?imageView2/0/q/80/w/9999/h/120/format/jpg',
  year: '2021',
  card_subtitle: '中国大陆 / 剧情 动画 奇幻 / 袁洁 自在天 / 锦鲤 刘晴',
  id: '35312003',
  null_rating_reason: ''
}
{
  rating: { count: 289073, max: 10, star_count: 4.5, value: 9.1 },
  controversy_reason: '',
  title: '完美的世界',
  abstract: '',
  has_linewatch: true,
  uri: 'douban://douban.com/movie/1300992',
  cover_url: 'https://qnmob3.doubanio.com/view/photo/large/public/p2190556408.jpg?imageView2/0/q/80/w/9999/h/120/format/jpg',
  year: '1993',
  card_subtitle: '美国 / 剧情 犯罪 / 克林特·伊斯特伍德 / 凯文·科斯特纳 劳拉·邓恩',
  id: '1300992',
  null_rating_reason: ''
}
{
  rating: { count: 7007, max: 10, star_count: 4, value: 8.1 },
  controversy_reason: '',
  title: '完美的世界',
  abstract: '',
  has_linewatch: true,
  uri: 'douban://douban.com/tv/30449306',
  cover_url: 'https://qnmob3.doubanio.com/view/photo/large/public/p2553489875.jpg?imageView2/0/q/80/w/9999/h/120/format/jpg',
  year: '2019',
  card_subtitle: '日本 / 剧情 爱情 / 三宅喜重 白木启一郎 / 松坂桃李 山本美月',
  id: '30449306',
  null_rating_reason: ''
}
{
  rating: { count: 896, max: 10, star_count: 3, value: 5.9 },
  controversy_reason: '',
  title: '完美世界',
  abstract: '',
  has_linewatch: false,
  uri: 'douban://douban.com/movie/27056187',
  cover_url: 'https://qnmob3.doubanio.com/view/photo/large/public/p2528181720.jpg?imageView2/0/q/80/w/9999/h/120/format/jpg',
  year: '2018',
  card_subtitle: '日本 / 剧情 爱情 / 柴山健次 / 岩田刚典 杉咲花',
  id: '27056187',
  null_rating_reason: ''
}
{
  rating: { count: 67, max: 10, star_count: 4, value: 8.1 },
  controversy_reason: '',
  title: '完美世界 特别番外篇',
  abstract: '',
  has_linewatch: false,
  uri: 'douban://douban.com/tv/33400542',
  cover_url: 'https://qnmob3.doubanio.com/view/photo/large/public/p2554177000.jpg?imageView2/0/q/80/w/9999/h/120/format/jpg',
  year: '2019',
  card_subtitle: '日本 / 剧情 爱情 / 滨弘大 / 山本美月 濑户康史',
  id: '33400542',
  null_rating_reason: ''
}
{
  rating: { count: 346, max: 10, star_count: 3.5, value: 6.5 },
  controversy_reason: '',
  title: '完美世界',
  abstract: '',
  has_linewatch: false,
  uri: 'douban://douban.com/movie/4189830',
  cover_url: 'https://qnmob3.doubanio.com/view/photo/large/public/p1662987188.jpg?imageView2/0/q/80/w/9999/h/120/format/jpg',
  year: '2010',
  card_subtitle: '日本 / 剧情 科幻 悬疑 / 浪川大辅 / 宫野真守 森久保祥太郎',
  id: '4189830',
  null_rating_reason: ''
}
{
  rating: { count: 1283, max: 10, star_count: 3.5, value: 6.8 },
  controversy_reason: '',
  title: '美好世界终结时',
  abstract: '',
  has_linewatch: false,
  uri: 'douban://douban.com/movie/25967447',
  cover_url: 'https://qnmob3.doubanio.com/view/photo/large/public/p2207316911.jpg?imageView2/0/q/80/w/9999/h/120/format/jpg',
  year: '2015',
  card_subtitle: '日本 / 喜剧 奇幻 同性 / 松居大悟 / 桥本爱 苍波纯',
  id: '25967447',
  null_rating_reason: ''
}
*/
const search = async (keyword) => {
  const res = await call({
    url: '/search/weixin',
    params: {
      q: keyword,
      start: 0,
      count: 20,
    }
  });
  if (res)
    return res.items.filter(item => item.target_type === 'movie' || item.target_type === 'tv').map(item => ({id: item.target_id, type: item.target_type, ...item.target}));
  return []
}

// movie detail
/*
{
  rating: { count: 1251963, max: 10, star_count: 4.5, value: 9.3 },
  lineticket_url: '',
  controversy_reason: '',
  pubdate: [ '2003-09-05(中国大陆)' ],
  last_episode_number: null,
  interest_control_info: null,
  pic: {
    large: 'https://img2.doubanio.com/view/photo/m_ratio_poster/public/p2564556863.jpg',
    normal: 'https://img2.doubanio.com/view/photo/s_ratio_poster/public/p2564556863.jpg'
  },
  year: '2002',
  vendor_count: 5,
  body_bg_color: 'f4f9f8',
  is_tv: false,
  head_info: null,
  album_no_interact: false,
  ticket_price_info: '',
  webisode_count: 0,
  can_rate: true,
  card_subtitle: '2002 / 中国香港 / 剧情 犯罪 惊悚 / 刘伟强 麦兆辉 / 刘德华 梁朝伟',
  forum_info: null,
  webisode: null,
  id: '1307914',
  gallery_topic_count: 0,
  languages: [ '粤语' ],
  genres: [ '剧情', '犯罪', '惊悚' ],
  review_count: 1712,
  variable_modules: [
    { sub_modules: [], id: 'rating' },
    { sub_modules: [], id: 'other_interests' },
    { sub_modules: [], id: 'video_photos' },
    { sub_modules: [Array], id: 'share' },
    { sub_modules: [], id: 'related_items' },
    { sub_modules: [Array], id: 'comments' },
    { sub_modules: [], id: 'honor_infos' },
    { sub_modules: [], id: 'interest' },
    { sub_modules: [Array], id: 'ugc_tabs' }
  ],
  title: '无间道',
  intro: '1991年，香港黑帮三合会会员刘健明（刘德华）听从老大韩琛（曾志伟）的吩咐，加入警察部队成为黑帮卧底，韩琛许诺刘健明会帮其在七年后晋升为见习督察。1992年，警察训练学校优秀学员陈永仁（梁朝伟）被上级要求深入到三合会做卧底，终极目标是成为韩琛身边的红人。2002年，两人都不负重望，也都身背重压，刘健明渐想成为一个真正的好人，陈永仁则盼着尽快回归警察身份。\n' +
    '重案组从陈永仁手中获悉一批毒品交易情报，锁紧目标人物韩琛，没料情报被刘健明泄出，双方行动均告失败。但此事将双方均有卧底的事实暴露，引发双方高层清除内鬼的决心。命运迥异又相似的刘健明和陈永仁开始在无间道的旅程中接受严峻考验。',
  interest_cmt_earlier_tip_title: '发布于上映前',
  has_linewatch: true,
  vendors: [
    {
      labels: [],
      click_trackings: [Array],
      book_type_cn: '',
      payment_desc: 'VIP免费观看',
      id: 'bilibili',
      impression_trackings: [Array],
      app_uri: 'bilibili://skynet.douban.com',
      title: '哔哩哔哩',
      app_bundle_id: 'tv.danmaku.bili',
      click_tracking: '',
      is_ad: false,
      impression_tracking: '',
      promote_desc: '',
      book_type: '',
      icon: 'https://img9.doubanio.com/f/frodo/88a62f5e0cf9981c910e60f4421c3e66aac2c9bc/pics/vendors/bilibili.png',
      grey_icon: 'https://img2.doubanio.com/f/frodo/306bfa7ea3d607e3525063ac6aea156b2ca163f5/pics/vendors/bilibili_grey.png',
      url: 'https://www.bilibili.com/bangumi/play/ss32395?bsource=douban',
      is_paid: true,
      uri: 'bilibili://bangumi/season/32395?url_from_h5=1',
      episodes_info: '',
      is_in_whitelist: false,
      payments: [Array],
      pre_release_desc: '',
      subject_id: '1307914'
    },
    {
      labels: [],
      click_trackings: [Array],
      book_type_cn: '',
      payment_desc: '免费观看',
      id: 'miguvideo',
      impression_trackings: [Array],
      app_uri: 'miguvideo://skynet.douban.com',
      title: '咪咕视频',
      app_bundle_id: 'com.cmcc.cmvideo',
      click_tracking: '',
      is_ad: true,
      impression_tracking: '',
      promote_desc: '',
      book_type: '',
      icon: 'https://img2.doubanio.com/f/frodo/8286b9b5240f35c7e59e1b1768cd2ccf0467cde5/pics/vendors/migu_video.png',
      grey_icon: 'https://img2.doubanio.com/f/frodo/b69fab25c7e056f34e5bea1408a03767d7a07153/pics/vendors/migu_video_grey.png',
      url: 'https://m.miguvideo.com/mgs/msite/prd/detail.html?cid=622793074&pwId=d01197d3076b4164af82983c408bb996',
      is_paid: true,
      uri: 'miguvideo://miguvideo?action=%7B%22params%22%3A%7B%22contentID%22%3A%22622793074%22%2C%22frameID%22%3A%22default-frame%22%2C%22location%22%3A%22H5%22%2C%22pageID%22%3A%2261fb7b0ec4c745bb97b90eb2b14b83c7%22%7D%2C%22type%22%3A%22JUMP_DETAIL_PAGE%22%7D',
      episodes_info: '',
      is_in_whitelist: false,
      payments: [Array],
      pre_release_desc: '',
      subject_id: '1307914'
    },
    {
      labels: [],
      click_trackings: [Array],
      book_type_cn: '',
      payment_desc: '免费观看',
      id: 'xigua',
      impression_trackings: [Array],
      app_uri: 'snssdk32://skynet.douban.com',
      title: '西瓜视频',
      app_bundle_id: 'com.ss.android.article.video',
      click_tracking: '',
      is_ad: false,
      impression_tracking: '',
      promote_desc: '',
      book_type: '',
      icon: 'https://img1.doubanio.com/f/frodo/5210c818dacf60d61d49b208845e85195bff17b7/pics/vendors/xigua.png',
      grey_icon: 'https://img2.doubanio.com/f/frodo/3a6b7335083cf537f2952369555ca6b943ba9520/pics/vendors/xigua_grey.png',
      url: 'https://www.ixigua.com/6532729694318494215?logTag=c3f243b884550e94a6b1',
      is_paid: true,
      uri: 'snssdk32://lvideo_detail?album_id=6532729694318494215',
      episodes_info: '',
      is_in_whitelist: false,
      payments: [Array],
      pre_release_desc: '',
      subject_id: '1307914'
    },
    {
      labels: [],
      click_trackings: [Array],
      book_type_cn: '',
      payment_desc: 'VIP免费观看',
      id: 'iqiyi',
      impression_trackings: [Array],
      app_uri: 'iqiyi://skynet.douban.com',
      title: '爱奇艺',
      app_bundle_id: 'com.qiyi.video',
      click_tracking: '',
      is_ad: false,
      impression_tracking: '',
      promote_desc: '',
      book_type: '',
      icon: 'https://img9.doubanio.com/f/frodo/634a77c4a77d80a2a4f49ed7aaf0bc076fec7d01/pics/vendors/iqiyi.png',
      grey_icon: 'https://img2.doubanio.com/f/frodo/4e4fdeaa34319e8ad48533489b7857dfea5bd31c/pics/vendors/iqiyi_grey.png',
      url: 'http://www.iqiyi.com/v_19rrjefg34.html?vfm=m_331_dbdy&fv=4904d94982104144a1548dd9040df241',
      is_paid: false,
      uri: 'iqiyi://mobile/player?aid=92343900&tvid=92343900&ftype=27&subtype=333',
      episodes_info: '',
      is_in_whitelist: false,
      payments: [Array],
      pre_release_desc: '',
      subject_id: '1307914'
    },
    {
      labels: [],
      click_trackings: [Array],
      book_type_cn: '',
      payment_desc: 'VIP免费观看',
      id: 'qq',
      impression_trackings: [Array],
      app_uri: 'tenvideo2://skynet.douban.com',
      title: '腾讯视频',
      app_bundle_id: 'com.tencent.qqlive',
      click_tracking: '',
      is_ad: false,
      impression_tracking: '',
      promote_desc: '',
      book_type: '',
      icon: 'https://img9.doubanio.com/f/frodo/6a2f30e0091339d45ff19fd8a5a48235c733fe69/pics/vendors/tencent.png',
      grey_icon: 'https://img2.doubanio.com/f/frodo/8200258235dae64145f57e3fd17f0c7cfff0b06c/pics/vendors/tencent_grey.png',
      url: 'http://v.qq.com/x/cover/sg5p4qp1s6jbyj8.html?ptag=douban.movie',
      is_paid: false,
      uri: 'tenvideo2://?action=1&cover_id=sg5p4qp1s6jbyj8&video_id=o0025wzpzfw&from=douban.doc_m',
      episodes_info: '',
      is_in_whitelist: false,
      payments: [Array],
      pre_release_desc: '',
      subject_id: '1307914'
    }
  ],
  forum_topic_count: 654,
  ticket_promo_text: '',
  webview_info: {},
  is_released: true,
  comment_count: 202881,
  actors: [
    { name: '刘德华' },
    { name: '梁朝伟' },
    { name: '黄秋生' },
    { name: '曾志伟' },
    { name: '郑秀文' },
    { name: '陈慧琳' },
    { name: '陈冠希' },
    { name: '余文乐' },
    { name: '林家栋' },
    { name: '萧亚轩' }
  ],
  interest: null,
  subtype: 'movie',
  episodes_count: 0,
  color_scheme: {
    is_dark: true,
    primary_color_light: '557269',
    _base_color: [ 0.45, 0.2586206896551724, 0.4549019607843137 ],
    secondary_color: 'f4f9f8',
    _avg_color: [ 0.4540229885057471, 0.24166666666666664, 0.47058823529411764 ],
    primary_color_dark: '384c46'
  },
  type: 'movie',
  linewatches: [
    {
      url: 'http://v.qq.com/x/cover/sg5p4qp1s6jbyj8.html?ptag=douban.movie',
      source: [Object],
      source_uri: 'tenvideo2://?action=1&cover_id=sg5p4qp1s6jbyj8&video_id=o0025wzpzfw&from=douban.doc_m',
      free: false
    }
  ],
  info_url: 'https://www.douban.com/doubanapp//h5/movie/1307914/desc',
  tags: [],
  durations: [ '101分钟', '97分钟(导演剪辑版)' ],
  cover: {
    description: '',
    author: {
      loc: null,
      kind: 'user',
      name: '🌈🎨🧁🍭🎉🎡🎊',
      url: 'https://www.douban.com/people/147347194/',
      id: '147347194',
      reg_time: '2016-06-21 06:22:42',
      uri: 'douban://douban.com/user/147347194',
      avatar_side_icon_id: '',
      avatar: 'https://img1.doubanio.com/icon/up147347194-17.jpg',
      is_club: false,
      type: 'user',
      avatar_side_icon: '',
      uid: 'Savelinour'
    },
    url: 'https://movie.douban.com/photos/photo/2564556863/',
    image: {
      large: [Object],
      raw: null,
      small: [Object],
      is_animated: false,
      normal: [Object]
    },
    uri: 'douban://douban.com/photo/2564556863',
    create_time: '2019-08-02 14:56:13',
    position: 0,
    owner_uri: 'douban://douban.com/movie/1307914',
    type: 'photo',
    id: '2564556863',
    sharing_url: 'https://www.douban.com/doubanapp/dispatch?uri=/photo/2564556863/'
  },
  cover_url: 'https://img2.doubanio.com/view/photo/m_ratio_poster/public/p2564556863.jpg',
  restrictive_icon_url: '',
  header_bg_color: '384c46',
  is_douban_intro: true,
  ticket_vendor_icons: [
    'https://img9.doubanio.com/view/dale-online/dale_ad/public/0589a62f2f2d7c2.jpg'
  ],
  honor_infos: [
    {
      kind: 'top250',
      uri: 'douban://douban.com/subject_collection/movie_top250',
      rank: 17,
      title: '豆瓣电影Top250'
    }
  ],
  sharing_url: 'https://movie.douban.com/subject/1307914/',
  subject_collections: [
    {
      is_follow: false,
      title: '高分经典犯罪片榜',
      id: 'film_genre_46',
      uri: 'douban://douban.com/subject_collection/film_genre_46?type=rank&category=movie&rank_type=film_genre'
    },
    {
      is_follow: false,
      title: '中国香港犯罪片榜',
      id: 'EC3AOZZUY',
      uri: 'douban://douban.com/subject_collection/EC3AOZZUY?type=rank&category=movie&rank_type=film_genre'
    },
    {
      is_follow: false,
      title: '高分黑帮电影榜',
      id: 'ECZ4PG5QI',
      uri: 'douban://douban.com/subject_collection/ECZ4PG5QI?type=rank&category=movie&rank_type=film_genre'
    }
  ],
  wechat_timeline_share: 'screenshot',
  countries: [ '中国香港' ],
  rate_info: '',
  release_date: null,
  original_title: '無間道',
  uri: 'douban://douban.com/movie/1307914',
  pre_playable_date: null,
  episodes_info: '',
  url: 'https://movie.douban.com/subject/1307914/',
  directors: [ { name: '刘伟强' }, { name: '麦兆辉' } ],
  is_show: false,
  null_rating_reason: '',
  vendor_icons: [
    'https://img9.doubanio.com/f/frodo/88a62f5e0cf9981c910e60f4421c3e66aac2c9bc/pics/vendors/bilibili.png',
    'https://img2.doubanio.com/f/frodo/8286b9b5240f35c7e59e1b1768cd2ccf0467cde5/pics/vendors/migu_video.png',
    'https://img1.doubanio.com/f/frodo/5210c818dacf60d61d49b208845e85195bff17b7/pics/vendors/xigua.png'
  ],
  pre_release_desc: '',
  video: {
    sharing_url: 'https://www.douban.com/doubanapp/dispatch?uri=/movie/1307914/video%3Fvideo_id%3D106088%26video_type%3DA',
    video_url: 'https://sv1.doubanio.com/202209061741/70ad5052f3536181f37378a2ef742a97/video/2020/M/401060088.mp4',
    title: '为什么《无间道》能成就港片影史第一神作！',
    author: {
      loc: [Object],
      reg_time: '2008-03-16 14:39:14',
      followed: false,
      name: '口袋电影君',
      avatar_side_icon: '',
      url: 'https://www.douban.com/people/2308894/',
      gender: 'M',
      uri: 'douban://douban.com/user/2308894',
      avatar: 'https://img3.doubanio.com/icon/up2308894-10.jpg',
      id: '2308894',
      remark: '',
      avatar_side_icon_id: '',
      in_blacklist: false,
      is_club: false,
      type: 'user',
      kind: 'user',
      uid: 'petergy'
    },
    uri: 'douban://douban.com/movie/1307914/video?video_id=106088&video_type=A',
    cover_url: 'https://img1.doubanio.com/view/photo/photo/public/p2609241458.jpg?',
    n_comments: 1,
    create_time: '2020-06-17',
    file_size: 0,
    runtime: '03:13',
    type: 'A',
    id: '106088',
    desc: '豆瓣9.2！为什么《无间道》三部曲能成就港片影史第一神作！'
  },
  aka: [ 'Infernal Affairs', 'Mou gaan dou' ],
  is_restrictive: false,
  trailer: {
    sharing_url: 'https://www.douban.com/doubanapp/dispatch?uri=/movie/1307914/trailer%3Ftrailer_id%3D137473%26trailer_type%3DA',
    video_url: 'https://vt1.doubanio.com/202209061740/378a10461336a72ba9b0418389df4d1e/view/movie/M/301370473.mp4',
    title: '美国预告片',
    uri: 'douban://douban.com/movie/1307914/trailer?trailer_id=137473&trailer_type=A',
    cover_url: 'https://img1.doubanio.com/img/trailer/medium/2022844188.jpg?',
    term_num: 0,
    n_comments: 41,
    create_time: '2013-07-02',
    subject_title: '无间道',
    file_size: 6970556,
    runtime: '01:16',
    type: 'A',
    id: '137473',
    desc: ''
  },
  interest_cmt_earlier_tip_desc: '该短评的发布时间早于公开上映时间，作者可能通过其他渠道提前观看，请谨慎参考。其评分将不计入总评分。'
}
*/
const movieDetail = (id) => {
  return call({
    url: '/movie/' + id,
  });
}

// tv detail
/*
{
  rating: { count: 384921, max: 10, star_count: 5, value: 9.5 },
  lineticket_url: '',
  controversy_reason: '',
  pubdate: [ '2011-04-17(美国)' ],
  last_episode_number: null,
  interest_control_info: null,
  pic: {
    large: 'https://img1.doubanio.com/view/photo/m_ratio_poster/public/p896064368.jpg',
    normal: 'https://img1.doubanio.com/view/photo/s_ratio_poster/public/p896064368.jpg'
  },
  year: '2011',
  vendor_count: 1,
  body_bg_color: 'f4f9f9',
  is_tv: true,
  head_info: {
    uri: 'douban://douban.com/tv/3016187/forum_topics',
    title: '5008人正在热议'
  },
  album_no_interact: false,
  ticket_price_info: '',
  webisode_count: 0,
  can_rate: true,
  card_subtitle: '2011 / 美国 英国 / 剧情 奇幻 冒险 / 蒂莫西·范·帕腾 布莱恩·柯克 丹尼尔·米纳汉 阿兰·泰勒 / 肖恩·宾 米歇尔·费尔利',
  forum_info: {
    id: 'tv/3016187',
    participant_count: 5008,
    uri: 'douban://douban.com/tv/3016187/forum_topics'
  },
  webisode: null,
  id: '3016187',
  gallery_topic_count: 0,
  languages: [ '英语', '多斯拉克语' ],
  genres: [ '剧情', '奇幻', '冒险' ],
  review_count: 565,
  variable_modules: [
    { sub_modules: [], id: 'rating' },
    { sub_modules: [], id: 'other_interests' },
    { sub_modules: [], id: 'video_photos' },
    { sub_modules: [Array], id: 'share' },
    { sub_modules: [], id: 'related_items' },
    { sub_modules: [Array], id: 'comments' },
    { sub_modules: [], id: 'honor_infos' },
    { sub_modules: [], id: 'interest' },
    { sub_modules: [Array], id: 'ugc_tabs' }
  ],
  title: '权力的游戏 第一季',
  intro: '《权力的游戏》是一部中世纪史诗奇幻题材的电视连续剧，该剧以美国作家乔治·R·R·马丁的奇幻巨作《冰与火之歌》七部曲为基础改编创作。\n' +
    '故事背景中虚构的世界，分为两片大陆：位于西面的“日落国度”维斯特洛；位于东面的类似亚欧大陆。维斯特洛大陆边境处发现远古传说中早已灭绝的生物开始，危险也渐渐在靠近这里。这片大陆的临冬城主暨北境统领艾德史塔克家族也迎来了老友兼国王劳勃·拜拉席恩的来访。国王希望艾德·史塔克（肖恩·宾 Sean Bean 饰）能担任首相一职，对抗企图夺取铁王座的叛军。危情一触即发，整个王国看似平和的表面下却是波涛暗涌。权高位重的拜拉席恩家族、勇敢善良的史塔克家族、企图谋取王位的坦格利安家族、有着不可告人秘密的兰尼斯特家族。这些家族各怀鬼胎，这个国家将会陷入一场混战.....',
  interest_cmt_earlier_tip_title: '发布于上映前',
  has_linewatch: true,
  vendors: [
    {
      labels: [],
      click_trackings: [Array],
      book_type_cn: '',
      payment_desc: '免费观看',
      id: 'qq',
      impression_trackings: [Array],
      app_uri: 'tenvideo2://skynet.douban.com',
      title: '腾讯视频',
      app_bundle_id: 'com.tencent.qqlive',
      click_tracking: '',
      is_ad: false,
      impression_tracking: '',
      promote_desc: '',
      book_type: '',
      icon: 'https://img9.doubanio.com/f/frodo/6a2f30e0091339d45ff19fd8a5a48235c733fe69/pics/vendors/tencent.png',
      grey_icon: 'https://img2.doubanio.com/f/frodo/8200258235dae64145f57e3fd17f0c7cfff0b06c/pics/vendors/tencent_grey.png',
      url: 'http://v.qq.com/x/page/y0016tj0qvh.html?ptag=douban.tv',
      is_paid: false,
      uri: 'tenvideo2://?action=1&cover_id=zf2z0xpqcculhcz&video_id=y0016tj0qvh&from=douban.doc_m',
      episodes_info: '10集全',
      is_in_whitelist: false,
      payments: [Array],
      pre_release_desc: '',
      subject_id: '3016187'
    }
  ],
  forum_topic_count: 460,
  ticket_promo_text: '',
  webview_info: {},
  is_released: true,
  comment_count: 73752,
  actors: [
    { name: '肖恩·宾' },
    { name: '米歇尔·费尔利' },
    { name: '琳娜·海蒂' },
    { name: '彼特·丁拉基' },
    { name: '艾米莉亚·克拉克' },
    { name: '基特·哈灵顿' },
    { name: '苏菲·特纳' },
    { name: '麦茜·威廉姆斯' },
    { name: '尼古拉·科斯特-瓦尔道' },
    { name: '伊恩·格雷' },
    { name: '约翰·布莱德利' }
  ],
  interest: null,
  subtype: 'tv',
  episodes_count: 10,
  color_scheme: {
    is_dark: true,
    primary_color_light: '6e7272',
    _base_color: [ 0.5, 0.03333333333333333, 0.11764705882352941 ],
    secondary_color: 'f4f9f9',
    _avg_color: [ 0, 0, 0.1607843137254902 ],
    primary_color_dark: '494c4c'
  },
  type: 'tv',
  linewatches: [
    {
      url: 'http://v.qq.com/x/page/y0016tj0qvh.html?ptag=douban.tv',
      source: [Object],
      source_uri: 'tenvideo2://?action=1&cover_id=zf2z0xpqcculhcz&video_id=y0016tj0qvh&from=douban.doc_m',
      free: true
    }
  ],
  info_url: 'https://www.douban.com/doubanapp//h5/movie/3016187/desc',
  tags: [],
  durations: [ '60分钟' ],
  cover: {
    description: '',
    author: {
      loc: [Object],
      kind: 'user',
      name: '20个小明≯',
      url: 'https://www.douban.com/people/23344187/',
      id: '23344187',
      reg_time: '2009-11-09 12:01:26',
      uri: 'douban://douban.com/user/23344187',
      avatar_side_icon_id: '',
      avatar: 'https://img9.doubanio.com/icon/up23344187-64.jpg',
      is_club: false,
      type: 'user',
      avatar_side_icon: '',
      uid: 'W3IQ7'
    },
    url: 'https://movie.douban.com/photos/photo/896064368/',
    image: {
      large: [Object],
      raw: null,
      small: [Object],
      is_animated: false,
      normal: [Object]
    },
    uri: 'douban://douban.com/photo/896064368',
    create_time: '2011-03-16 23:29:26',
    position: 0,
    owner_uri: 'douban://douban.com/tv/3016187',
    type: 'photo',
    id: '896064368',
    sharing_url: 'https://www.douban.com/doubanapp/dispatch?uri=/photo/896064368/'
  },
  cover_url: 'https://img1.doubanio.com/view/photo/m_ratio_poster/public/p896064368.jpg',
  restrictive_icon_url: '',
  header_bg_color: '494c4c',
  is_douban_intro: true,
  ticket_vendor_icons: [
    'https://img9.doubanio.com/view/dale-online/dale_ad/public/0589a62f2f2d7c2.jpg'
  ],
  honor_infos: [
    {
      kind: 'rank',
      uri: 'douban://douban.com/subject_collection/ECHU473PI?type=rank&category=movie&rank_type=tv_genre',
      rank: 1,
      title: '奇幻类美剧榜'
    }
  ],
  sharing_url: 'https://movie.douban.com/subject/3016187/',
  subject_collections: [
    {
      is_follow: false,
      title: '高分经典美剧榜',
      id: 'ECVACWVGI',
      uri: 'douban://douban.com/subject_collection/ECVACWVGI?type=rank&category=movie&rank_type=tv_genre'
    },
    {
      is_follow: false,
      title: '权力的游戏',
      id: 'ECGEHCH2Q',
      uri: 'douban://douban.com/subject_collection/ECGEHCH2Q?type=rank&category=movie&rank_type=series'
    }
  ],
  wechat_timeline_share: 'screenshot',
  countries: [ '美国', '英国' ],
  rate_info: '',
  release_date: null,
  original_title: 'Game of Thrones Season 1',
  uri: 'douban://douban.com/tv/3016187',
  pre_playable_date: null,
  episodes_info: '',
  url: 'https://movie.douban.com/subject/3016187/',
  directors: [
    { name: '蒂莫西·范·帕腾' },
    { name: '布莱恩·柯克' },
    { name: '丹尼尔·米纳汉' },
    { name: '阿兰·泰勒' }
  ],
  is_show: false,
  null_rating_reason: '',
  vendor_icons: [
    'https://img9.doubanio.com/f/frodo/6a2f30e0091339d45ff19fd8a5a48235c733fe69/pics/vendors/tencent.png'
  ],
  pre_release_desc: '',
  video: null,
  aka: [
    '冰与火之歌：权力的游戏 第一季',
    '王座游戏 第一季',
    'A Song of Ice and Fire: Game of Thrones Season 1'
  ],
  is_restrictive: false,
  trailer: {
    sharing_url: 'https://www.douban.com/doubanapp/dispatch?uri=/tv/3016187/trailer%3Ftrailer_id%3D274178%26trailer_type%3DA',
    video_url: 'https://vt1.doubanio.com/202209071131/444fcd32d23f29e75293c3c8e45f5a94/view/movie/M/402740178.mp4',
    title: '预告片',
    uri: 'douban://douban.com/tv/3016187/trailer?trailer_id=274178&trailer_type=A',
    cover_url: 'https://img2.doubanio.com/img/trailer/medium/2638879912.jpg?',
    term_num: 0,
    n_comments: 4,
    create_time: '2021-04-06',
    subject_title: '权力的游戏 第一季',
    file_size: 36609238,
    runtime: '02:36',
    type: 'A',
    id: '274178',
    desc: ''
  },
  interest_cmt_earlier_tip_desc: '该短评的发布时间早于公开上映时间，作者可能通过其他渠道提前观看，请谨慎参考。其评分将不计入总评分。'
}
*/
const tvDetail = (id) => {
  return call({
    url: '/tv/' + id,
  });
}


module.exports = {
  setup, search, movieDetail, tvDetail
}